package com.example.shilehui;


import cn.jhc.service.DonatePlanService;
import android.app.Activity;
import android.graphics.Color;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.view.View.OnClickListener;
import android.widget.TextView;

public class DonatePlanTypeSelectionActivity extends Activity {

	private TextView _titleLeftTextView;
	private TextView _titleRightTextView;
	private TextView _titleMiddleTextView;
	private TextView _donateTypeByTopicTextView;
	private TextView _donateTypeByQuotaTextView;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		
		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		ini();
	}
	
	private void ini(){
		
		setContentView(R.layout.donate_plan_type_selection_layout);
		setTitleStyle();
		setPageStyle();
		
	}
	
	private void setTitleStyle(){
		_titleLeftTextView=(TextView)findViewById(R.id.user_login_title_left_text);
		_titleMiddleTextView=(TextView)findViewById(R.id.user_login_title_middle);
		_titleRightTextView=(TextView)findViewById(R.id.user_login_title_right_text);
		
		_titleLeftTextView.setText(getResources().getString(R.string.close));
		_titleLeftTextView.setTextColor(Color.WHITE);
		_titleLeftTextView.setTextSize(16);
		_titleMiddleTextView.setText(getResources().getString(R.string.donate_plan_selcet_type));	
		_titleMiddleTextView.setTextColor(Color.WHITE);
		_titleMiddleTextView.setTextSize(18);
		_titleRightTextView.setVisibility(View.GONE);
		
		
		_titleLeftTextView.setOnClickListener(new OnTitleClickListener());
		
	}
	
	private void setPageStyle(){
		
		_donateTypeByQuotaTextView=(TextView)findViewById(R.id.donata_plan_quota_textview);
		_donateTypeByTopicTextView=(TextView)findViewById(R.id.donata_plan_every_topic_textview);
		
		_donateTypeByQuotaTextView.setTextColor(Color.BLACK);
		_donateTypeByTopicTextView.setTextColor(Color.BLACK);
		
		_donateTypeByQuotaTextView.setOnClickListener(new onPageClickListener());
		_donateTypeByTopicTextView.setOnClickListener(new onPageClickListener());
		
		
	}
	
	
	private class OnTitleClickListener implements OnClickListener{

		@Override
		public void onClick(View v) {
			
			switch (v.getId()) {
			case R.id.user_login_title_left_text:
				finish();
				break;

			default:
				break;
			}
			
		}
		
	}
	
	
	private class onPageClickListener implements OnClickListener{

		@Override
		public void onClick(View v) {
			String text;
			switch (v.getId()) {
			
			case R.id.donata_plan_every_topic_textview:
				
				text=_donateTypeByTopicTextView.getText().toString();
				DonatePlanService.getInstance().setType(text);
				finish();
				
			break;
			
			case R.id.donata_plan_quota_textview:
				
				text=_donateTypeByQuotaTextView.getText().toString();
				DonatePlanService.getInstance().setType(text);
				finish();
			break;	
				
			default:
				break;
			}
			
		}
		
		
		
	}
	
	
	
}
